﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Student_dyzkz : System.Web.UI.Page
{
    DataClassesDataContext db = new DataClassesDataContext();
    private string wbh;
    protected void Page_Load(object sender, EventArgs e)
    {
        wbh = Session["wbh"].ToString();
                if ((db.proc_ISOpenDate(4)) < 1)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('该功能暂未开放，请等待！');window.location='../main.aspx'</script>");
                    return;
                }
            
            BindData();
    }
    private void BindData()
    {
        var schoolRes = (from p in db.proc_GetBkgxNowYear()
                         select p).ToList().First();
        la_SchoolName.Text = schoolRes.schoolName;
        la_BkYear.Text = schoolRes.dYear;
        string wbh = Session["wbh"].ToString().Trim();
        var result = (from p in db.StuInfo
                      where p.wbh == wbh
                      select p).ToList().First();
        switch (result.proflag)
        {
            case 0:
                ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('请先完成报名！');window.location='../main.aspx'</script>");
                return;
            case 1:
                ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('请先提交报名信息！');window.location='../main.aspx'</script>");
                return;
            case 2:
                ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('请先等待院校审核！');window.location='../main.aspx'</script>"); ;
                return;
            default:
                if (result.zKZflag == 1)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('请先等待院校审核通过！');window.location='../main.aspx'</script>"); ;
                    return;
                }
                break;
        }
        if (result.seatNo == null)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('考场安排正在编排中，请等待！');window.location='../Main.aspx'</script>");
            return;
        }
        img_Stu.ImageUrl = "~/Student/stuimage/" + result.sidfy + ".jpg";
        Label4.Text = result.sname;
        Label6.Text = result.proName;
        Label9.Text = result.gkbmh;
        Label5.Text = result.sdept;
        Label7.Text = result.sidfy;
        Label3.Text = result.zkzh;
        Label8.Text = (result.seatNo + 100).ToString().Substring(1, 2);
        var SubResult = from p in db.proc_GetStuSubjectInfoByWbh(wbh)
                        select p;
        rp_Grade.DataSource = SubResult;
        rp_Grade.DataBind();
    }
}